//
//  HYPreviewHistoryModel.m
//  XPlayer
//
//  Created by liguoqing on 2023/9/29.
//

#import "HYPreviewHistoryModel.h"

@implementation HYPreviewHistoryModel

+ (NSDictionary *)JSONKeyPathsByPropertyKey{
    return nil;
}

#pragma mark - LKDBHelper

+ (NSString *)getTableName{
    return @"HISTORY";
}

+ (NSString *)getPrimaryKey{
    return @"_id";
}

#pragma mark - DB Mapping

//! 数据库字段映射，key为数据库字段，value为属性
+ (NSDictionary *)tableMapping{
    return @{
        @"_id": @"_id",
        @"fileName":@"fileName",
        @"filePath":@"filePath",
        @"fileType":@"fileType",
        @"folderIdentification":@"folderIdentification",
        @"folderPath":@"folderPath",
        @"videoPlayTime":@"videoPlayTime",
        @"fileSize":@"fileSize",
        @"videoImagePath":@"videoImagePath",
        @"videoDuration":@"videoDuration",
        @"createDate":@"createDate",
        @"importDate":@"importDate",
        @"updateDate":@"updateDate",
        @"isPrivate":@"isPrivate"
    };
}

+ (HYPreviewHistoryModel *)getRecentlyReviewHistory
{
    HYPreviewHistoryModel *historyModel = [self fetchAllPreviewHistroyRecord].firstObject;
    return historyModel;
}

+ (NSArray *)fetchAllPreviewHistroyRecord
{
    NSString *sql = [NSString stringWithFormat:@"select *from HISTORY where isPrivate = '%d' order by updateDate DESC",0];
    return [HYPreviewHistoryModel searchWithSQL:sql];
}

+ (void)clearAllPreviewRecord
{
    [self deleteWithWhere:@"1"];
}

@end
